//
//  LSHomeViewController.swift
//  LSWeiBo0808
//
//  Created by 李明禄 on 2017/8/10.
//  Copyright © 2017年 SocererGroup. All rights reserved.
//

import UIKit

class LSHomeViewController: LSBaseViewController {

    var weibo = [String]()
    let cellID = "WEIBO"
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
    
        // Do any additional setup after loading the view.
    }
    
    override func loadData() {
       super.loadData()
        
//        for i in 1...20 {
//            weibo.append(i.description)
//        }
        
        DispatchQueue.main.asyncAfter(deadline: .now()+2) {
            for i in 1...4 {
                self.weibo.append(i.description)
            }
            self.downRefresh?.endRefreshing()
            self.tableview?.reloadData()
        }
    
    }
    

    @objc fileprivate func friendEvent() {
//        print("点击了好友")
        let VC = LSDemoViewController()
        navigationController?.pushViewController(VC, animated: true)
    }

}

extension LSHomeViewController {
    override func setupUI() {
        super.setupUI()
        
//        navItem.leftBarButtonItem = UIBarButtonItem(title: "好友", style: UIBarButtonItemStyle.plain, target: self, action: #selector(friendEvent))
        navItem.leftBarButtonItem = UIBarButtonItem(title: "好友", fontSize: 15, normalColor: .black, highlightedColor: .orange, target: self, action: #selector(friendEvent), controlEvents: UIControlEvents.touchUpInside)
        // 注册原型 cell
        tableview?.register(UITableViewCell.self, forCellReuseIdentifier: cellID)

    }
}

extension LSHomeViewController {
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return weibo.count
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableview?.dequeueReusableCell(withIdentifier: cellID, for: indexPath)
        
        cell?.textLabel?.text = weibo[indexPath.row]
        
        return cell!
    }
}
